@isTest
private class SalePerformanceDataCalcUtilTest {
    static testMethod void testMethod1() {

    	String wono = '001234';
    	String year = '2020年';
    	String quarter = '1';

    	//名单录入
    	SalesPerformanceDataSheet__c cs  = new SalesPerformanceDataSheet__c();
    	cs.Year__c = year;
    	cs.Quarter__c = quarter;
    	cs.EmployeeNumber__c = wono;
    	cs.AreaJobCategory__c = SalePerformanceDataCalcUtil.saler_zx;
    	cs.ProductJobCategory__c = SalePerformanceDataCalcUtil.saler_cpx;
    	cs.IncrementalJobCategory__c = SalePerformanceDataCalcUtil.saler_zx;
    	cs.AssessmentCategory__c = SalePerformanceDataCalcUtil.base_post;
    	cs.AreaSaccharifyRate__c = 0.55;
    	cs.AreaSurrogateReagentRate__c = 0.15;
    	cs.AreaInstrumentRate__c = 0.30;
    	cs.Areai3000Rate__c = 0.30;
    	cs.Areai1000Rate__c =0.15;
    	cs.AreaC800Rate__c = 0.1;
    	cs.AreaBloodCorpuscleRate__c = 0.2;
    	cs.AreaBloodClottingRate__c = 0.15;
    	cs.AreaBloodTypeRate__c = 0.05;
    	cs.AreaSaccharifyRate__c = 0.05;
    	cs.AreaOverdueRate__c = 0.2;
    	cs.BiochemistryRate__c = 0.15;
    	cs.ImmunityRate__c = 0.2;
    	cs.ImmunityRate__c = 0.1;
    	cs.AgentProductRate__c = 0.05;
    	cs.InstrumentRate__c = 0.2;
    	cs.i3000Rate__c = 0.3;
    	cs.i1000Rate__c = 0.15;
    	cs.C800Rate__c = 0.1;
    	cs.BloodCorpuscleRate__c = 0.2;
    	cs.BloodClottingRate__c	 = 0.15;
    	cs.BloodTypeRate__c = 0.05;
    	cs.SaccharifyRate__c = 0.05;
    	cs.OverdueRate__c = 0.1;
    	cs.SuperiorEvaluationRate__c = 0.2;
    	cs.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('PerformanceUser', 'SalesPerformanceDataSheet__c');
    	cs.Company__c  = 'MKSY';
    	//考核指标
    	SalesPerformanceDataSheet__c es  = new SalesPerformanceDataSheet__c();
    	es.Year__c = year;
    	es.Quarter__c = quarter;
    	es.EmployeeNumber__c = wono;
    	es.Company__c  = 'MKSY';
    	es.AreaOverdueScore__c = 0.20;
    	es.OverdueScore__c = 0.26;
    	es.SuperiorEvaluation__c = 0.55;
    	es.CRMDeduction__c = 0;
    	es.ReceivableDeduction__c = 0;
    	es.OverdueDeduction__c = 0;
    	es.MeasurementDeduction__c = -100;
    	cs.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('PerformanceTargetScore', 'SalesPerformanceDataSheet__c');

    	//基本试剂绩效
    	SalesPerformanceDataSheet__c base = new SalesPerformanceDataSheet__c();
    	base.Year__c = year;
    	base.Quarter__c = quarter;
    	base.EmployeeNumber__c = wono;
    	base.ReagentCategory__c =SalePerformanceDataCalcUtil.cate_sh;
    	base.ActualSalesQ1__c = 10000;
    	base.LastYearSalesVolumeQ1__c = 8000;
    	base.JobCategory__c = SalePerformanceDataCalcUtil.saler_zx;

    	base.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('ReagentPerformance', 'SalesPerformanceDataSheet__c');

    	//仪器
    	SalesPerformanceDataSheet__c equip = new SalesPerformanceDataSheet__c();
    	equip.Year__c = year;
    	equip.Quarter__c = quarter;
    	equip.EmployeeNumber__c = wono;
    	equip.InstrumentClasses__c = SalePerformanceDataCalcUtil.equip_i3000 ;
    	equip.ActualQuantityQ1__c = 3;
    	equip.BudgetQuantity__c = 2;
    	equip.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('InstrumentPerformance', 'SalesPerformanceDataSheet__c');

    	//试剂增量
    	SalesPerformanceDataSheet__c incr = new SalesPerformanceDataSheet__c();
    	incr.Year__c = year;
    	incr.Quarter__c = quarter;
    	incr.EmployeeNumber__c = wono;
    	incr.IncrementalCcategory__c =SalePerformanceDataCalcUtil.cate_sh;
    	incr.Category__c = '特殊项目';
    
    	incr.SalesMarket__c = SalePerformanceDataCalcUtil.market_zx;

    	incr.ActualSalesQ1__c = 10000;
    	incr.LastYearSalesVolumeQ1__c = 8000;
    	incr.JobCategory__c = SalePerformanceDataCalcUtil.saler_zx;
    	incr.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('ReagentIncrementalPerformance', 'SalesPerformanceDataSheet__c');

    	//代理试剂增量
    	SalesPerformanceDataSheet__c agent = new SalesPerformanceDataSheet__c();
        agent.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('AgentIncrementPerformance', 'SalesPerformanceDataSheet__c');
        agent.Year__c = year;
    	agent.Quarter__c = quarter;
    	agent.EmployeeNumber__c = wono;
    	agent.SalesMarket__c = SalePerformanceDataCalcUtil.market_zx;

    	//年度增量
    	SalesPerformanceDataSheet__c aIncr = new SalesPerformanceDataSheet__c();
        aIncr.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('AnnualIncrementPerformance', 'SalesPerformanceDataSheet__c');
        aIncr.Year__c = year;
    	aIncr.Quarter__c = quarter;
    	aIncr.EmployeeNumber__c = wono;
    	aIncr.SalesMarket__c = SalePerformanceDataCalcUtil.market_zx;


    	insert new List<SalesPerformanceDataSheet__c>{cs,es,base,equip,incr,agent,aIncr};

    	SalePerformanceDataCalcUtil.calcToResult(wono, year, quarter);

    	SalePerformanceDataCalcUtil.calcToResult(wono, year, '4');

    	new SalePerformanceDataCalcUtil(); 

        SalePerformanceDataCalcBatch sbacth = new SalePerformanceDataCalcBatch(year,quarter);
        Database.executeBatch(sbacth, 1);
        sbacth.init();


    }
}